from pygds import GDS
from py2neo import Graph


import pandas as pd

graph_link = Graph("http://localhost:7474", username="neo4j", password="123456")


def get_links(links_data):
    """知识图谱关系数据获取"""

    node_list = []
    for link in links_data:
        dict = {}
        dict['node_id'] = link['n'].identity
        dict['公司名称'] = link['n']['公司名称']
        node_list.append(dict)
    return node_list

node_cyper = 'match (n:`企业`) return n'
qiye_reuslt = graph_link.run(node_cyper).data()
df = pd.DataFrame(get_links(qiye_reuslt), columns=['node_id', '公司名称'])
print(df)
